using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Afrs.Draco.Prms.Client.Proxy;
using Afrs.Prms.DataObject;

namespace 
{
  /// <summary>
  /// LetterHeaderAndFooter Test Class
  /// </summary>
  [TestClass]
  public class TestLetterHeaderAndFooter
  {
    #region Class Variables
    private CdoPrms<DOLetterHeaderAndFooter>		m_LetterHeaderAndFooter;
    private CdoPrmsList<DOLetterHeaderAndFooter>	m_AllLetterHeaderAndFooter;
    #endregion

    #region Class Constructors & Destructors
    /// <summary>
    /// Constructs the test
    /// </summary>
    public TestLetterHeaderAndFooter()
    {
      // Create the data objects
      this.m_LetterHeaderAndFooter	= new CdoPrms<DOLetterHeaderAndFooter>();
      this.m_AllLetterHeaderAndFooter	= new CdoPrmsList<DOLetterHeaderAndFooter>();
    }
    #endregion

    #region Class Methods
    /// <summary>
    /// Retrieves all LetterHeaderAndFooter data objects
    /// </summary>
    [TestMethod]
    public void LetterHeaderAndFooterRetrieveAll()
    {
      // Set up the data object for list retrieval
      this.m_AllLetterHeaderAndFooter.DataObject = new DOLetterHeaderAndFooter();
      this.m_AllLetterHeaderAndFooter.ListAction = AfrsDOListAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_AllLetterHeaderAndFooter.PerformAction())
      {
        // Assert the errors
        if (this.m_AllLetterHeaderAndFooter.Errors.Count > 0) { Assert.Fail(this.m_AllLetterHeaderAndFooter.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Create a new LetterHeaderAndFooter
    /// </summary>
    [TestMethod]
    public void LetterHeaderAndFooterCreate()
    {
      // Set up the data object for creation
      this.m_LetterHeaderAndFooter.DataObject.HeaderFontSize = 12.3M;
      this.m_LetterHeaderAndFooter.DataObject.HeaderFontStyle = "Test HeaderFontStyle";
      this.m_LetterHeaderAndFooter.DataObject.HeaderText = "Test HeaderText";
      this.m_LetterHeaderAndFooter.DataObject.HeaderImagePath = "Test HeaderImagePath";
      this.m_LetterHeaderAndFooter.DataObject.FooterFont = "Test FooterFont";
      this.m_LetterHeaderAndFooter.DataObject.FooterFontSize = 12.3M;
      this.m_LetterHeaderAndFooter.DataObject.FooterFontStyle = "Test FooterFontStyle";
      this.m_LetterHeaderAndFooter.DataObject.FooterText = "Test FooterText";
      this.m_LetterHeaderAndFooter.DataObject.Action = AfrsDataObjectAction.Create;

      // Perform the action and determine the success
      if (!this.m_LetterHeaderAndFooter.PerformAction())
      {
        // Assert the errors
        if (this.m_LetterHeaderAndFooter.Errors.Count > 0) { Assert.Fail(this.m_LetterHeaderAndFooter.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Retrieves a specific LetterHeaderAndFooter
    /// </summary>
    [TestMethod]
    public void LetterHeaderAndFooterRetrieve()
    {
      // Determine whether the data object needs to be specified
      if (this.m_LetterHeaderAndFooter.DataObject.Id == 0)
      {
        // Specify the data object to retrieve
        this.m_LetterHeaderAndFooter.DataObject.HeaderFont = "Test HeaderFont";
      }

      // Set up the data object action for retrieval
      this.m_LetterHeaderAndFooter.DataObject.Action = AfrsDataObjectAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_LetterHeaderAndFooter.PerformAction())
      {
        // Assert the errors
        if (this.m_LetterHeaderAndFooter.Errors.Count > 0) { Assert.Fail(this.m_LetterHeaderAndFooter.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }
    #endregion
  }
}
